package org.jeecg.modules.yusuannz.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.json.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.yusuannz.entity.CaiwuYusuanNz;
import org.jeecg.modules.yusuannz.entity.NianDuHuiZongNz;
import org.jeecg.modules.yusuannz.service.ICaiwuYusuanNzService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;

 /**
 * @Description: caiwu_yusuan
 * @Author: jeecg-boot
 * @Date:   2020-06-15
 * @Version: V1.0
 */
@Api(tags="caiwu_yusuannz")
@RestController
@RequestMapping("/yusuan/caiwuYusuannz")
@Slf4j
public class CaiwuYusuanNzController extends JeecgController<CaiwuYusuanNz, ICaiwuYusuanNzService> {
	@Autowired
	private ICaiwuYusuanNzService caiwuYusuanService;
	@Autowired
	private ISysDepartService sysDepartService;

    @GetMapping("/nianduhuizong")
    public Result<?> nianduhuizong(@RequestParam(name="deptId",required = false) String deptId){
    	if(StringUtils.isBlank(deptId)){
    		String orgCode = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getOrgCode();
			deptId = this.sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getOrgCode,orgCode)).getId();
		}
    	List<NianDuHuiZongNz> list = this.caiwuYusuanService.nianduhuizong(deptId);
    	return Result.ok(list);
	}
}
